package com.xinfu.mooddiaryjava.ui.base;

import android.graphics.Color;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;

import com.kunminx.architecture.utils.BarUtils;
import com.xinfu.mooddiaryjava.App;
import com.xinfu.mooddiaryjava.bridge.callback.SharedViewModel;

public class BaseActivity extends AppCompatActivity {

    private SharedViewModel mSharedViewModel;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        BarUtils.setStatusBarColor(this, Color.TRANSPARENT);
        BarUtils.setStatusBarLightMode(this, true);

        mSharedViewModel = getAppViewModelProvider().get(SharedViewModel.class);

//        getLifecycle().addObserver(NetworkStateManager.getInstance());

    }

    protected ViewModelProvider getAppViewModelProvider(){
        return ((App)getApplicationContext()).getAppViewModelProvider(this);
    }

    protected ViewModelProvider getActivityViewModelProvider(AppCompatActivity appCompatActivity){
        return new ViewModelProvider(appCompatActivity, appCompatActivity.getDefaultViewModelProviderFactory());
    }
}
